/*
 * Copyright (C) 2016 The Fosafer Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.fosafer.idcard_demo.act;

import android.view.KeyEvent;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.fosafer.idcard_demo.R;
import com.fosafer.idcard_demo.util.AppManagerUtil;


/**
 * Package:      [com.fosafer.idcard_demo.act]
 * ClassName:    [TimeOutAct]
 * Description:  [超时提醒页面]
 * Author:       [cuijianzhi]
 * CreateDate:   [2016/09/08 15:22]
 * UpdateUser:   [cuijianzhi]
 * UpdateDate:   [2016/09/08 15:22]
 * UpdateRemark: [Update Description]
 * Version:      [v1.0.0]
 * <p>
 * Copyright (c) 2016 Fosafer Co.,Ltd. All rights reserved.
 */
public class TimeOutAct extends BaseAct implements View.OnClickListener {


    @Override
    protected void initView() {
        super.initView();
        ImageView act_timeout_iv_help = (ImageView) findViewById(R.id.act_timeout_iv_help);
        Button act_timeout_btn_retry = (Button) findViewById(R.id.act_timeout_btn_retry);
        TextView layout_top_tv_left = (TextView) findViewById(R.id.layout_top_tv_left);
        TextView layout_top_tv_title = (TextView) findViewById(R.id.layout_top_tv_title);
        layout_top_tv_title.setText(getString(R.string.tips_timeout_operate));
        layout_top_tv_left.setVisibility(View.VISIBLE);
        layout_top_tv_left.setOnClickListener(this);
        act_timeout_btn_retry.setOnClickListener(this);
        act_timeout_iv_help.setImageDrawable(getResources().getDrawable(R.drawable.timeout_face));
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.act_timeout_btn_retry:
                finish();
                break;
            case R.id.layout_top_tv_left:
                closeActs();
                break;
        }
    }

    @Override
    public int getContentViewLayoutId() {
        return R.layout.act_timeout;
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            closeActs();
        }
        return true;
    }

    /**
     * 关掉前面的页面
     */
    private void closeActs() {
        AppManagerUtil.getInstance().finishAct("FaceVerifyAct");
        finish();
    }

}
